package com.venusj.springcloud.controller;

import com.venusj.springcloud.entity.Payment;
import com.venusj.springcloud.result.CommonResult;
import com.venusj.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhangjh
 * @date 2020/3/22
 */
@RestController
@Slf4j
@RequestMapping("/payment")
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @Value("${server.port}")
    private String port;

    @PostMapping(value = "/create")
    public CommonResult create(@RequestBody Payment payment) {
       return paymentService.create(payment);
    }

    @GetMapping(value = "/get/{id}")
    public CommonResult create(@PathVariable("id") Long id) {
        return paymentService.getPaymentById(id);
    }

    @GetMapping(value = "/lb")
    public String getPaymentLb() {
        return port;
    }

}
